package com.eveinfo.api.utils.skilllist;

import java.io.Serializable;
import java.util.ArrayList;

public class ApiSkillGroup implements Serializable {
	
	private static final long serialVersionUID = 1454617584612839158L;
	
	private String groupName;
	private int groupID;
	
	private final ArrayList<ApiSkill> skills = new ArrayList<ApiSkill>();

	public String getGroupName() {
		return groupName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}

	public int getGroupID() {
		return groupID;
	}

	public void setGroupID(int groupID) {
		this.groupID = groupID;
	}

	public void addSkill(ApiSkill skill) {
		skills.add(skill);
	}

	public ArrayList<ApiSkill> getSkills() {
		return skills;
	}

	public int countSkill(){
		return skills.size();
	}
	
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		for(ApiSkill skill : skills){
			sb.append("   "+skill.getTypeName()+"\n");
		}
		return sb.toString();
	}

	public ApiSkill getSkillWithPosition(int i) {
		return skills.get(i);
	}
	
	public ApiSkill getSkill(int skillId){
		for(ApiSkill skill : skills){
			if(skill.getTypeID() == skillId){
				return skill;
			}
		}
		return null;
	}
	
	public String getSkillName(int skillId){
		for(ApiSkill skill : skills){
			if(skill.getTypeID() == skillId){
				return skill.getTypeName();
			}
		}
		return null;
	}

	public boolean contains(int skillId) {
		for(ApiSkill skill : skills){
			if(skill.getTypeID() == skillId){
				return true;
			}
		}
		return false;
	}
	
	public boolean removeSkill(ApiSkill skill){
		return skills.remove(skill);
	}
	
}